package net.html;

import java.awt.EventQueue;
import java.awt.Frame;

import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.WindowConstants;

public class Fibonacci
{
	public static void main(String[] args)
	{
		StringBuffer result = new StringBuffer("<html><title>fibonacci</title><ol>");
		long f1 = 0;
		long f2 = 1;
		for (int i = 0; i < 50; i++)
		{
			result.append("<li>");
			result.append(f1);
			long temp = f2;
			f2 = f1 + f2;
			f1 = temp;
		}
		result.append("</ol></body></html>");
		JEditorPane jep = new JEditorPane("text/html",result.toString());
		jep.setEditable(false);
		
		JScrollPane jScrollPane = new JScrollPane(jep);
		JFrame f = new JFrame("Febonacci sequence");
		f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		f.setContentPane(jScrollPane);
		f.setSize(555,333);
		EventQueue.invokeLater(new FrameShower(f));
	}
	private static class FrameShower implements Runnable
	{
		private final Frame frame;
		@Override
		public void run()
		{
			this.frame.setVisible(true);
		}
		public FrameShower(Frame frame)
		{
			this.frame = frame;
		}
	}
}
